//
//  MainViewController.m
//  Select
//
//  Created by dihuijun on 17/3/15.
//  Copyright © 2017年 Cycle. All rights reserved.
//

#import "MainViewController.h"
//tableView单选
#import "SignalTableViewController.h"
//#import "SignalViewController.h"
//tableView多选
#import "MutipTableViewController.h"
//#import "MutViewController.h"
//collection单选
#import "SignalCollectionViewController.h"
//collection多选
#import "MutipCollectionViewController.h"
@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"单选多选";

    
   /***     1.1 tableView单选   ***/
    UIButton *signalTableButton  = [self setupButtonWithTitle:@"tableView单选" Selector:@selector(clickSignalTable)];
    [self.view addSubview:signalTableButton];
    //布局
    [signalTableButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left).offset(20);
        make.top.mas_equalTo(self.view.mas_top).offset(80);
        make.right.mas_equalTo(self.view.mas_right).offset(-20);
        make.height.mas_equalTo(50);
    }];
    
    /****    1.2 tableView多选 ***/
    UIButton *mutipTableButton = [self setupButtonWithTitle:@"tableView多选" Selector:@selector(ClickMutipTable)];
    [self.view addSubview:mutipTableButton];
    //布局
    [mutipTableButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left).offset(20);
        make.top.mas_equalTo(signalTableButton.mas_bottom).offset(20);
        make.right.mas_equalTo(self.view.mas_right).offset(-20);
        make.height.mas_equalTo(50);
    }];
    
    /**  1.3 collection单选**/
    UIButton *signalCollection = [self setupButtonWithTitle:@"collection单选" Selector:@selector(ClickSignalCollection:)];
    [self.view addSubview:signalCollection];
    //布局
    [signalCollection mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left).offset(20);
        make.top.mas_equalTo(mutipTableButton.mas_bottom).offset(20);
        make.right.mas_equalTo(self.view.mas_right).offset(-20);
        make.height.mas_equalTo(50);
    }];
    /**  1.4 collection多选**/
    UIButton *mutipCollection = [self setupButtonWithTitle:@"collection多选" Selector:@selector(ClickMutipCollection:)];
    [self.view addSubview:mutipCollection];
    //布局
    [mutipCollection mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left).offset(20);
        make.top.mas_equalTo(signalCollection.mas_bottom).offset(20);
        make.right.mas_equalTo(self.view.mas_right).offset(-20);
        make.height.mas_equalTo(50);
    }];
    

}

#pragma mark --- 1.1  tableView单选
- (void)clickSignalTable
{
    NSLog(@"tableView单选");
    
    [self.navigationController pushViewController:[SignalTableViewController new] animated:YES];
    
}
#pragma mark --- 1.2 tableView多选｀
- (void)ClickMutipTable
{
    NSLog(@"tableView多选");
    [self.navigationController pushViewController:[MutipTableViewController new] animated:YES];
}
#pragma mark --- 1.3 collection单选
- (void)ClickSignalCollection:(UIButton *)button{
    NSLog(@"collection单选");
    [self.navigationController pushViewController:[SignalCollectionViewController new] animated:YES];
}
#pragma mark --- 1.4 collection多选
- (void)ClickMutipCollection:(UIButton *)button{
    NSLog(@"collection多选");
    [self.navigationController pushViewController:[MutipCollectionViewController new] animated:YES];
}



























#pragma mark ---- 创建按钮方法
- (UIButton *)setupButtonWithTitle:(NSString *)title Selector:(SEL)selector{
    UIButton    *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setTitle:title forState:UIControlStateNormal];
    
    [button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    
    [button setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
    
    [button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
    
    button.backgroundColor  = [UIColor lightGrayColor];
    
    return button;
}

@end
